home *** CD-ROM | disk | FTP | other *** search
/ Language/OS - Multiplatform Resource Library / LANGUAGE OS.iso / a_utils / perl / msds-prl / perl419x.zoo / eg / drives.bat < prev    next >
DOS Batch File  |  1992-02-23  |  1KB  |  43 lines

  1. @REM=(qq!
  2. @perl %0.bat %1 %2 %3 %4 %5 %6 %7 %8 %9
  3. @goto end !) if 0 ;
  4. #
  5. # Test the ioctl function for MS-DOS.  Provide a list of drives and their
  6. # characteristics.
  7. #
  8. # By Diomidis Spinellis.
  9. #
  10.  
  11. @fdnum = ("STDIN", "STDOUT", "STDERR");
  12. $maxdrives = 15;
  13. for ($i = 3; $i < $maxdrives; $i++) {
  14.     open("FD$i", "nul");
  15.     @fdnum[$i - 1] = "FD$i";
  16. }
  17. @mediatype = (
  18.     "320/360 k floppy drive",
  19.     "1.2M floppy",
  20.     "720K floppy",
  21.     "8'' single density floppy",
  22.     "8'' double density floppy",
  23.     "fixed disk",
  24.     "tape drive",
  25.     "1.44M floppy",
  26.     "other"
  27. );
  28. print "The system has the following drives:\n";
  29. for ($i = 1; $i < $maxdrives; $i++) {
  30.     if ($ret = ioctl(@fdnum[$i], 8, 0)) {
  31.         $type = ($ret == 0) ? "removable" : "fixed";
  32.         $ret = ioctl(@fdnum[$i], 9, 0);
  33.         $location = ($ret & 0x800) ? "local" : "remote";
  34.         ioctl(@fdnum[$i], 0x860d, $param);
  35.         @par = unpack("CCSSSC31S", $param);
  36.         $lock = (@par[2] & 2) ? "supporting door lock" : "not supporting door lock";
  37.         printf "%c:$type $location @mediatype[@par[1]] @par[3] cylinders @par[6]
  38.  sectors/track $lock\n", ord('A') + $i - 1;
  39.     }
  40. }
  41. @REM=(qq!
  42. :end !) if 0 ;
  43.